package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 霍森彪
 * @date 2022/7/15 15:56
 */

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult channelList(){
        return wmChannelService.channelList();
    }

    //admin新增频道
    @PostMapping("/save")
    public ResponseResult channelSave(@RequestBody WmChannel channel){
        return wmChannelService.channelSave(channel);
    }

    //admin查询频道列表
    @PostMapping("/list")
    public PageResponseResult listChannel(@RequestBody ChannelDto dto) {
        return wmChannelService.listChannel(dto);
    }

    //admin修改频道
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel channel){
        return wmChannelService.updateChannel(channel);
    }

    //删除频道
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id")Integer id){
        return wmChannelService.deleteChannel(id);
    }


}
